package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.ISysDashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 首页仪表板数据
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/system/dashboard")
public class SysDashboardController extends BaseController
{
    @Autowired
    private ISysDashboardService dashboardService;

    /**
     * 获取首页统计数据
     */
    @GetMapping("/stats")
    public AjaxResult getStats()
    {
        Map<String, Object> stats = dashboardService.getStats();
        return success(stats);
    }

    /**
     * 获取运单趋势数据
     * @param period 时间段：7days, 30days, 90days
     */
    @GetMapping("/waybillTrend")
    public AjaxResult getWaybillTrend(@RequestParam(defaultValue = "7days") String period)
    {
        Map<String, Object> trendData = dashboardService.getWaybillTrend(period);
        return success(trendData);
    }

    /**
     * 获取运单状态分布数据
     */
    @GetMapping("/waybillStatus")
    public AjaxResult getWaybillStatus()
    {
        Map<String, Object> statusData = dashboardService.getWaillStatus();
        return success(statusData);
    }

    /**
     * 获取计划进度数据
     */
    @GetMapping("/planProgress")
    public AjaxResult getPlanProgress()
    {
        Map<String, Object> progressData = dashboardService.getPlanProgress();
        return success(progressData);
    }
}
